package red.stu.wechat.factory.robot;

import java.io.File;
import java.util.logging.Handler;

import me.xuxiaoxiao.chatapi.wechat.WeChatClient;
import me.xuxiaoxiao.chatapi.wechat.entity.message.WXMessage;

/**
 * 微信机器人
 * @author yihrmc
 *
 */
public class WeChatRobot {
	
	/**
	 * 机器人ID
	 */
	public final String rid;
	
	/**
	 * wechat
	 */
	public final WeChatClient client;
	
	WeChatRobot (String rid, WeChatRoobotCallback callback, File folder, Handler handler) {
		this.rid = rid;
		client = new WeChatClient(new WeChatClient.WeChatListener() {

			@Override
			public void onQRCode(String qrCode) {
				callback.onQRCode(rid, qrCode);
			}
			
			@Override
			public void onAvatar(String base64Avatar) {
				callback.onAvatar(rid, base64Avatar);
			}
			
			@Override
			public void onFailure(String reason) {
				callback.onFailure(rid, reason);
			}
			
			@Override
			public void onLogin() {
				callback.onLogin(rid);
			}
			
			@Override
			public void onLogout() {
				callback.onLogout(rid);
			}
			
			@Override
			public void onMessage(WXMessage message) {
				callback.onMessage(rid, message);
			}
			
		}, folder, handler);
	}
	
}
